{% extends theme("base.html") %}
{% block list_bar %}
    <nav class="navbar container  bg-success" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand text-danger">搜索结果：</a>
        </div>
        <div class="collapse navbar-collapse">
            <form class="nav navbar-nav navbar-form navbar-right" action="{{ url_for('main.search') }}" method="POST"
                  role="search">
                {{ g.search_form.hidden_tag() }}
                <div class="form-group">
                    {{ g.search_form.search(class="form-control " ,placeholder="搜索本站") }}
                </div>
                <button type="submit" class="btn btn-warning "><span class="glyphicon glyphicon-search"></span>搜索
                </button>
            </form>
        </div>
    </nav>
    <br/>
{% endblock %}
{% block content %}
    <div class=" container center-block">
        <div class="container-fluid">
            {% for art in article.items %}
                <div class="jumbotron">

                    {% if g.user.is_authenticated() and g.user.is_admin() %}
                        <a class="btn-round btn btn-lg" data-trigger="tooltip" data-content="编辑此文"
                           data-position="e"
                           title="点击编辑"
                           href="{{ url_for('article.edit',id=art.id) }}"><h2>{{ art.title }}</h2></a>
                    {% else %}
                        <h2>{{ art.title }}</h2>
                    {% endif %}
                    <p>{{ art.text[:300]+'...' }}</p>

                    <div class="text-left ">
                        <p><a class="btn btn-primary btn-lg" role="button"
                              href="{{ url_for('article.show',aid=art.id) }}">
                            学习更多</a>
                        </p>
                        标签:
                        {% for t in art.tag.split(' ') %}
                            <a href="{{ url_for('main.search_result', sch=t, page=1) }}"> {{ t }} </a>
                        {% endfor %}
                        <div class="pull-right">
                            访问次数：<span class="badge"><small class="h6">{{ art.numlook }}</small></span>
                            最后编辑于：{{ art.timestamp }}
                        </div>
                    </div>
                </div>
            {% endfor %}
            <div class="text-left">
                <ul class="pager">
                    {% if article.has_prev %}
                        <li class="previous">
                            <a href="{{ url_for('main.search_result', sch=search, page=article.prev_num) }}">&larr;
                                Newer</a>
                        </li>
                    {% else %}
                        <li class="previous disabled">
                            <a>&larr; Newer</a>
                        </li>
                    {% endif %}
                    第{{ article.page }}页/共{{ article.pages }}页
                    {% if article.has_next %}
                        <li class="next"><a
                                href="{{ url_for('main.search_result', sch=search, page=article.next_num) }}">Older &rarr;</a>
                        </li>
                    {% else %}
                        <li class="next disabled"><a>Older &rarr;</a></li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </div>
{% endblock %}